<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="s_pro" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="addProcessRangSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 工序列表 </span>
      </div>
      <el-table :data="s_pro" @selection-change="handleSelectionChange">
        <el-table-column label="#" align="center" type='selection'>
        </el-table-column>
        <el-table-column label="#" align="center" type='index'>
        </el-table-column>
        <el-table-column label="工序条形码" prop="process_barcode">
        </el-table-column>
        <el-table-column label="工序名称" prop="process_name">
        </el-table-column>
        <el-table-column label="工序编号" prop="process_num">
        </el-table-column>
        <el-table-column label="变更状态" prop="process_state">
        </el-table-column>
        <el-table-column label="工序描述" prop="process_des">
        </el-table-column>
        <el-table-column label="开始时间" prop="process_begindate">
        </el-table-column>
        <el-table-column label="结束时间" prop="process_endate">
        </el-table-column>
      </el-table>
      <el-button @click="addProcessRangSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <pagination v-show="total>0" :total="total" :limit.sync="pageSize" @pagination="getPage" />
    </el-form>
    <el-dialog :visible.sync="ChoiceProcessRangVisible" append-to-body>
      <ChoiceProcessRang v-if="ChoiceProcessRangVisible" ref="ChoiceProcessRang" :popparams="popparams"> </ChoiceProcessRang>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import ChoiceProcessRang from "@/views/mes/product/ChoiceProcessRang";
  export default {
    name: 'AddProcessRang',
    components: {
      ChoiceProcessRang,
    },
    props: ['popparams'],
    data() {
      return {
        ChoiceProcessRangVisible: false,
        ChoiceProcessRangValue: null,
        ChoiceProcessRangDesc: null,
        vueparams: this.getVUEParams(""),
        s_pro: [],
        loading: false,
        elcheck: [],
        multiple: true,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/product/TechnologyAction/addProcessRang?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      addProcessRangSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/product/TechnologyAction/addProcessRangSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/mes/product/TestingItemsRang/testingItemsRang?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      popChoiceProcessRang(desc, value) {
        this.ChoiceProcessRangVisible = true;
        this.ChoiceProcessRangDesc = desc;
        this.ChoiceProcessRangValue = value;
      },
      closeChoiceProcessRang(value, desc) {
        this.ChoiceProcessRangVisible = false;
        this.$set(this.check_step, this.ChoiceProcessRangDesc, desc);
        this.$set(this.check_step, this.ChoiceProcessRangValue, value);
      },
      handleSelectionChange(selection) {
        this.elcheck = selection.map(item => item["process_id"]);
        this.single = selection.length != 1;
        this.multiple = !selection.length;
      },
    },
  }
</script>
